package com.lin.wx.pament.controller;

import com.lin.wx.pament.component.notify.NotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 支付回调通知
 */
@RestController
@RequestMapping("/pub/payment/callback")
public class CallbackController {
    @Autowired
    private NotifyService notifyService;

    /**
     * 统一回调通知，支持json传参和url传参,{product} -> 支付产品（如，wechat-jsapi）
     *
     * @return
     */
    @RequestMapping(value = "/notify/{product}", method = {RequestMethod.GET, RequestMethod.POST})
    public Map<String, Object> callbackNotify(@PathVariable("product") String product, @RequestBody(required = false) String body) {
        return notifyService.callbackNotify(product, body);
    }
}